/*
	解法：暴力匹配 或 KMP 或 return haystack.find(needle);
	为什么：选朴素匹配，KMP减少了时间复杂度但难想
			可以举个例子 主串 aabaabaaf
						 子串 aabaaf
	时间复杂度：O(n * m)，空间复杂度：O(1)
 */

#include <iostream>
#include <string>

using namespace std;

class Solution
{
public:
	int strStr(string haystack, string needle)
	{
		int n = static_cast<int>(haystack.length());
		int m = static_cast<int>(needle.length());
		
		if (m == 0)
		{
			return 0;
		}
		
		for (int i = 0; i <= n - m; i++)
		{
			int j = 0;
			while (j < m && haystack[i + j] == needle[j])
			{
				j++;
			}
			if (j == m)
			{
				return i;
			}
		}
		
		return -1;
	}
};

int main()
{
	string haystack, needle;
	cin >> haystack >> needle;
	
	Solution solution;
	int result = solution.strStr(haystack, needle);
	
	cout << result << endl;
	
	return 0;
}





